import { get, post } from '@/utils/request'

const prefix = 'layout'

export default {
  /**
   * 页面布局
   */
  page: data => {
    return get(`${prefix}/default/index`, data)
  },
  /**
   * 页面布局
   */
  pageView: id => {
    return get(`${prefix}/default/view`, {
      id: id
    })
  },
  /**
   * 页面布局
   */
  decorate: id => {
    return get(`${prefix}/decorate/view`, {
      id: id
    })
  },
  /**
   * 首页布局
   */
  homePage: data => {
    return get(`${prefix}/home/index`, data)
  },
  /**
   * 首页布局
   */
  zonePage: data => {
    return get(`${prefix}/zone/index`, data)
  },
  saveDecorate: (id, data) => {
    return post(`${prefix}/decorate/update?id=${id}`, data)
  },
  preview: data => {
    return post(`${prefix}/page/preview`, data, {
      responseType: 'arraybuffer'
    })
  },
  sourceParams: source => {
    return get(`${prefix}/source/params`, {
      name: source
    })
  },
  tabConfig: (id, pageId) => {
    return get(`${prefix}/tab/update`, {
      id: id,
      pid: pageId
    })
  },
  updateTab: (data, id, pageId) => {
    return post(`${prefix}/tab/update?id=${id}&pid=${pageId}`, data)
  }
}
